<div class="form">

    <?php echo $this->renderPartial('../layouts/mensagemErro', array('model' => $model)); ?>
    
    <?php
        $form = $this->beginWidget('CActiveForm', array(
            'id' => 'usuario-form',
            'enableAjaxValidation' => false,
        ));
    ?>
    <p class="note">Campos com <span class="required">*</span> são obrigatórios.</p>

    <?php echo $form->errorSummary($model); ?>

    <div class="row">
        <?php echo $form->labelEx($model, 'TX_NOME'); ?>
        <?php echo $form->textField($model, 'TX_NOME', array('size' => 60, 'maxlength' => 80)); ?>
        <?php echo $form->error($model, 'TX_NOME'); ?>
    </div>
    <?php if(Yii::app()->user->identity->isAdmin()): ?>
    <div class="row">
        <?php echo $form->labelEx($model, 'ID_PERFIL'); ?>
        <?php
            $dados = $model->getPerfis();
            echo $form->dropDownList($model, 'ID_PERFIL', $dados);
        ?>
        <?php echo $form->error($model, 'ID_PERFIL'); ?>
    </div>
    <div class="row">
        <?php
            if ($model->isNewRecord == false){
                echo $form->labelEx($model, 'ID_SITUACAO');
                $dados = $model->getSituacoes(false);
                if ($model->ID_SITUACAO != 0) {
                    echo $form->dropDownList($model, 'ID_SITUACAO', $dados);
                }else{
                    echo '<span class="required">Aguardando confirmação do e-mail cadastrado.</span>';
                }
                echo $form->error($model, 'ID_SITUACAO');
            }
        ?>
    </div>
    <?php endif; ?>
    <div class="row">
        <?
            $mail = explode('@', $model->TX_EMAIL);
            $model->TX_EMAIL = $mail[0];
            echo $form->labelEx($model, 'TX_EMAIL'); 
            echo $form->textField($model, 'TX_EMAIL', array('size' => 20, 'maxlength' => 50));
            echo '<span>@inf.ufrgs.br</span>';
            echo $form->error($model, 'TX_EMAIL');
        ?>
    </div>
    <div class="row">
        <?php
            echo $form->labelEx($model, 'TX_SENHA');
            echo $form->passwordField($model, 'TX_SENHA', array('size' => 50, 'maxlength' => 50));
            echo $form->error($model, 'TX_SENHA');
        ?>
    </div>
    <?php if(Yii::app()->user->identity->getId() == $model->ID_USUARIO): ?>
    <div class="row">
        <?php
            echo $form->labelEx($model, 'senha');
            echo $form->passwordField($model, 'senha', array('size' => 50, 'maxlength' => 50));
            echo $form->error($model, 'senha');
        ?>
    </div><div class="row">
        <?php
            echo $form->labelEx($model, 'confirmaSenha');
            echo $form->passwordField($model, 'confirmaSenha', array('size' => 50, 'maxlength' => 50));
            echo $form->error($model, 'confirmaSenha');
        ?>
    </div>
    <?php endif; ?>
    <div class="row buttons">
        <?php echo CHtml::submitButton($model->isNewRecord ? 'Criar' : 'Salvar'); ?>
    </div>

<?php $this->endWidget(); ?>

</div><!-- form -->